package cn.kingshion.springbootjdbcmysql.cn.kingshion.controller;

import cn.kingshion.springbootjdbcmysql.cn.kingshion.pojo.Users;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    JdbcTemplate jdbcTemplate;

    public List<Map<String, Object>> userList() {
        String sql = "select * from users;";
        List<Map<String, Object>> maps = jdbcTemplate.queryForList(sql);
        return maps;
    }


    public String addUser() {
        Users users = new Users();
        users.setUsername("boot");
        users.setPassword("boot");
        users.setDesc("boot");

        String sql = "insert into users(username,password,desc) values(${user.getUsername})";
        return null;

    }


}
